<html>
<head><meta charset="utf-8"><title>SIGABRT; ran out of registers during register allocation · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html">SIGABRT; ran out of registers during register allocation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232114468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232114468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232114468">(Mar 27 2021 at 20:00)</a>:</h4>
<p>Does anyone have hypotheses for what might be going on with the test failure in <a href="https://github.com/rust-lang/rust/pull/81825">https://github.com/rust-lang/rust/pull/81825</a> ?</p>



<a name="232114501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232114501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232114501">(Mar 27 2021 at 20:00)</a>:</h4>
<div class="codehilite" data-code-language="Text only"><pre><span></span><code>---- [ui] ui/abi/stack-probes-lto.rs stdout ----

error: test compilation failed although it shouldn't!
status: signal: 6 (core dumped)
command: "/checkout/obj/build/i686-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/abi/stack-probes-lto.rs" "-Zthreads=1" "--target=i686-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-o" "/checkout/obj/build/i686-unknown-linux-gnu/test/ui/abi/stack-probes-lto/a" "-Crpath" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-C" "lto" "-L" "/checkout/obj/build/i686-unknown-linux-gnu/test/ui/abi/stack-probes-lto/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
rustc: /checkout/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp:883: void {anonymous}::RegAllocFast::defineVirtReg(llvm::MachineInstr&amp;, unsigned int, llvm::Register, bool): Assertion `PhysReg != 0 &amp;&amp; "Register not assigned"' failed.
error: ran out of registers during register allocation

------------------------------------------
</code></pre></div>



<a name="232114525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232114525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232114525">(Mar 27 2021 at 20:01)</a>:</h4>
<div class="codehilite" data-code-language="Text only"><pre><span></span><code>---- [ui] ui/panic-runtime/lto-unwind.rs stdout ----

error: test compilation failed although it shouldn't!
status: signal: 6 (core dumped)
command: "/checkout/obj/build/i686-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/panic-runtime/lto-unwind.rs" "-Zthreads=1" "--target=i686-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-o" "/checkout/obj/build/i686-unknown-linux-gnu/test/ui/panic-runtime/lto-unwind/a" "-Crpath" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-C" "lto" "-C" "panic=unwind" "-L" "/checkout/obj/build/i686-unknown-linux-gnu/test/ui/panic-runtime/lto-unwind/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
rustc: /checkout/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp:883: void {anonymous}::RegAllocFast::defineVirtReg(llvm::MachineInstr&amp;, unsigned int, llvm::Register, bool): Assertion `PhysReg != 0 &amp;&amp; "Register not assigned"' failed.
------------------------------------------
</code></pre></div>



<a name="232114603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232114603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232114603">(Mar 27 2021 at 20:02)</a>:</h4>
<p>I have <em>no</em> idea how that might be related to the PR.</p>



<a name="232114613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232114613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232114613">(Mar 27 2021 at 20:02)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="302700">@Dominik Stolz</span></p>



<a name="232115047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232115047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232115047">(Mar 27 2021 at 20:09)</a>:</h4>
<p>seems like an LLVM bug? I would expect it to spill to the stack if it doesn't have enough registers</p>



<a name="232115065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232115065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232115065">(Mar 27 2021 at 20:09)</a>:</h4>
<p>yeah, that PR doesn't touch compiler/ at all so it's either a bug in rustc or llvm</p>



<a name="232115147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232115147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232115147">(Mar 27 2021 at 20:10)</a>:</h4>
<p>not necessarily, you can write a code that is valid but requires more registers than available.</p>



<a name="232115162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232115162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232115162">(Mar 27 2021 at 20:10)</a>:</h4>
<p>inline assembly allocating too many generic registers being a trivial way to trigger this kind of scenario.</p>



<a name="232115174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232115174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232115174">(Mar 27 2021 at 20:11)</a>:</h4>
<p>Needs minimization to tell for sure.</p>



<a name="232124264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232124264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232124264">(Mar 27 2021 at 22:57)</a>:</h4>
<p>If this were a six-argument syscall I'd be worried about that, but this is a two-argument syscall.</p>



<a name="232124268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232124268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232124268">(Mar 27 2021 at 22:57)</a>:</h4>
<p>So yeah, trying to reduce it seems like a good call.</p>



<a name="232150008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232150008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232150008">(Mar 28 2021 at 07:43)</a>:</h4>
<p>The <code>syscall!</code> macro doesn't actually codegen into a function that uses <code>asm!</code> to directly call a syscall. Instead it first tries to call a (weak) function with the same name to allow for <code>LD_PRELOAD</code> interception and if it isn't found it uses the <code>syscall</code> libc function to perform the syscall without wrapper. Because it is part of libc, LLVM never sees any (inline) assembly.</p>
<p><a href="https://github.com/rust-lang/rust/blob/fd2df74902fa98bcb71f85fd548c3eb399e6a96a/library/std/src/sys/unix/weak.rs#L121-L143">https://github.com/rust-lang/rust/blob/fd2df74902fa98bcb71f85fd548c3eb399e6a96a/library/std/src/sys/unix/weak.rs#L121-L143</a></p>



<a name="232179993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/SIGABRT%3B%20ran%20out%20of%20registers%20during%20register%20allocation/near/232179993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/SIGABRT.3B.20ran.20out.20of.20registers.20during.20register.20allocation.html#232179993">(Mar 28 2021 at 17:17)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> Ah, good to know. That makes it even more mystifying that this change could lead to a register allocation failure.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>